#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    bool isMonotonic(vector<int>& nums)
    {
        return is_sorted(nums.begin(), nums.end()) 
            || is_sorted(nums.rbegin(), nums.rend());
    }
};